﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DatabaseAccessLayer;

namespace WebApplication
{
    public partial class Company_Registration : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                List<CompType> lst = PropertyMgmt.GetEngComp();
                chkEnggComp.DataSource = lst;
                chkEnggComp.DataTextField = "Name";
                chkEnggComp.DataValueField = "ID";
                chkEnggComp.DataBind();

                List<CompType> lst1 = PropertyMgmt.GetConComp();
                chkConComp.DataSource = lst1;
                chkConComp.DataTextField = "Name";
                chkConComp.DataValueField = "ID";
                chkConComp.DataBind();

                List<CompType> lst2 = PropertyMgmt.GetMatComp();
                chkMatComp.DataSource = lst2;
                chkMatComp.DataTextField = "Name";
                chkMatComp.DataValueField = "ID";
                chkMatComp.DataBind();

            }

            ((System.Web.UI.HtmlControls.HtmlGenericControl)Master.FindControl("divbreadcrum")).InnerHtml = @"<a href='default.aspx'>Home</a> > <a href='Sign-In.aspx'>Sign In</a> > <a href='Membership.aspx'>New Registration</a> > <span>Membership</span>";
        }
        public void btnSubmit_Click(object sender, EventArgs e)
        {
            int UserID;
            string EnggComp = ""; string MatComp = ""; string ConComp = ""; string EnggCompOther = ""; string MatCompOther = ""; string ConCompOther = "";
            string EnggCompDesc = ""; string MatCompDesc = ""; string ConCompDesc = "";

            UserID = Convert.ToInt32(Request.QueryString["ID"]);
            foreach (ListItem item in chkEnggComp.Items)
            {
                if (item.Selected)
                {
                    EnggComp = EnggComp + item.Value + ",";
                }
            }

            foreach (ListItem item in chkMatComp.Items)
            {
                if (item.Selected)
                {
                    MatComp = MatComp + item.Value + ",";
                }
            }

            foreach (ListItem item in chkConComp.Items)
            {
                if (item.Selected)
                {
                    ConComp = ConComp + item.Value + ",";
                }
            }

            EnggCompOther = txtEnggCompOther.Text.Trim();
            MatCompOther = txtMatCompOther.Text.Trim();
            ConCompOther = txtConCompOther.Text.Trim();

            EnggCompDesc = txtEnggCompDesc.Text.Trim();
            MatCompDesc = txtMatCompDesc.Text.Trim();
            ConCompDesc = txtConCompDesc.Text.Trim();
            int Result = clsUser.MemberShipRegistrationComp(UserID,EnggComp,MatComp,ConComp,EnggCompOther,MatCompOther,ConCompOther,EnggCompDesc,MatCompDesc,ConCompDesc );
            if (Result>0)
            {
                Response.Redirect("Membership-Complete.aspx?ID=" + UserID);
            }

        }
    }
}